import numpy as np
import platgo as pg

"""
\min g^{t e}(x | \lambda, z^*)=\max \{\lambda_{i}(f_{i}(x)-z_{i}^{*})\}
"""


def tchebycheff(pop: pg.Population, weights: np.ndarray, Z: np.ndarray) -> np.ndarray:
    """
    切比雪夫权重分解
    :param pop:
    :param weights:
    :param Z: 理想点
    :return: 返回权重聚合后的目标函数值, shape=(T,)
    """
    objv = pop.objv
    # assert objv.shape == weights.shape
    ans = np.max((objv - Z) * weights, axis=1)
    return ans
